<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryData($event)"
  (onReset)="resetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-2">
  <div class="opera-wrap">
    <button
      nz-button
      nzType="primary"
      [nzLoading]="exportLoading"
      (click)="exportTable()"
    >导出</button>

    <span class="m-l-10">
      支出：<b>{{ statisticsData.sumAmount || '0' }}</b>元，成功订单数：<b>{{ statisticsData.number || '0' }}</b>
    </span>
  </div>

  <div class="pagination-wrap-position p-t-15">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="120px" nzLeft>用户ID</th>
          <th nzAlign="center" nzWidth="150px">手机号码</th>
          <th nzAlign="center" nzWidth="150px">应用ID</th>
          <th nzAlign="center" nzWidth="160px">应用名称</th>
          <th nzAlign="center" nzWidth="180px">渠道</th>
          <th nzAlign="center" nzWidth="170px">发生时间</th>
          <th nzAlign="center" nzWidth="170px">完成时间</th>
          <th nzAlign="center" nzWidth="180px">消费订单号</th>
          <th nzAlign="center" nzWidth="240px">厂商订单号</th>
          <th nzAlign="center" nzWidth="120px">兑换金额</th>
          <th nzAlign="center" nzWidth="120px">状态</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- 用户ID -->
          <td nzAlign="center" nzLeft>{{ data.userId }}</td>
          <!-- 手机号码 -->
          <td nzAlign="center">{{ data.phone || '-' }}</td>
          <!-- 应用ID -->
          <td nzAlign="center">{{ data.appId }}</td>
          <!-- 应用名称 -->
          <td nzAlign="center">{{ data.appName || '-' }}</td>
          <!-- 渠道 -->
          <td nzAlign="center">
            {{ filterText(channelOptions, data.walletId, 'content') }}
          </td>
          <!-- 发生时间 -->
          <td nzAlign="center">{{ data.createTime || '-' }}</td>
          <!-- 完成时间 -->
          <td nzAlign="center">{{ data.updateTime || '-' }}</td>
          <!-- 消费订单号 -->
          <td nzAlign="center">{{ data.changeNo || '-' }}</td>
          <!-- 厂商订单号 -->
          <td nzAlign="center">{{ data.billNo !== '0' ? data.billNo : '-' }}</td>
          <!-- 兑换金额 -->
          <td nzAlign="center">{{ data.amount || '-' }}</td>
          <!-- 状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.payStatus | divideConsumeStatus: 'color'}">
              {{ data.payStatus | divideConsumeStatus: 'label' }}
            </span>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>